package io.renren.modules.substation.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.substation.entity.TSampSoundInfoEntity;
import io.renren.modules.substation.service.TSampSoundInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 声音传感器采样数据
 *
 * @author TJH
 * @email sunlightcs@gmail.com
 * @date 2020-09-27 21:40:17
 */
@RestController
@RequestMapping("substation/tsampsoundinfo")
public class TSampSoundInfoController {
    @Autowired
    private TSampSoundInfoService tSampSoundInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("substation:tsampsoundinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tSampSoundInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("substation:tsampsoundinfo:info")
    public R info(@PathVariable("id") Long id){
		TSampSoundInfoEntity tSampSoundInfo = tSampSoundInfoService.getById(id);

        return R.ok().put("tSampSoundInfo", tSampSoundInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("substation:tsampsoundinfo:save")
    public R save(@RequestBody TSampSoundInfoEntity tSampSoundInfo){
		tSampSoundInfoService.save(tSampSoundInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("substation:tsampsoundinfo:update")
    public R update(@RequestBody TSampSoundInfoEntity tSampSoundInfo){
		tSampSoundInfoService.updateById(tSampSoundInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("substation:tsampsoundinfo:delete")
    public R delete(@RequestBody Long[] ids){
		tSampSoundInfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
